﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace GodofTroll
{
    public class Camera
    {
        //Variaveis de movimentaçao da camera
        public Matrix transform; // Chama a camera no Draw 
        //Viewport view;          // Nao sei pra que serve!!!
        
        // Variaveis para o posicionamento da camera em relacao ao personRectangle
        public Vector2 posicaoCamera;

        //Torna a classe Game1 acessivel por aqui
        Game1 game1 = new Game1();
        Controles controles = new Controles();

        //Variaveis para zoom pelo Scroll
        float escalaZoom = 1.0f;

        public Camera(Viewport newView)
        {
            //view = newView;
        }

        public int WidthView
        {
            get { return game1.graphics.PreferredBackBufferWidth; }
        }

        public int HeightView
        {
            get { return game1.graphics.PreferredBackBufferHeight; }
        }

        public void Update(GameTime gameTime, Game1 game1)
        {
            if (controles.currentKeyboard.IsKeyDown(Keys.PageDown))
            { escalaZoom -= 0.1f; }
            if (controles.currentKeyboard.IsKeyDown(Keys.PageUp))
            { escalaZoom += 0.1f; }

            posicaoCamera.X = game1.personRectangle.X - (WidthView / 2);
            posicaoCamera.Y = game1.personRectangle.Y - (HeightView / 2);
            if (posicaoCamera.X < 0)
            {
                posicaoCamera.X = 0;
            }
            if (posicaoCamera.Y < 0)
            {
                posicaoCamera.Y = 0;
            }

            transform = Matrix.CreateScale(escalaZoom) * Matrix.CreateTranslation(new Vector3(-posicaoCamera, 0));
            
         }

        
    }
}